package example

import (
	
	"github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/model/example"
    exampleReq "github.com/flipped-aurora/gin-vue-admin/server/model/example/request"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type UniversityStudentScoreApi struct {}



// CreateUniversityStudentScore 创建学成绩
// @Tags UniversityStudentScore
// @Summary 创建学成绩
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body example.UniversityStudentScore true "创建学成绩"
// @Success 200 {object} response.Response{msg=string} "创建成功"
// @Router /USS/createUniversityStudentScore [post]
func (USSApi *UniversityStudentScoreApi) CreateUniversityStudentScore(c *gin.Context) {
	var USS example.UniversityStudentScore
	err := c.ShouldBindJSON(&USS)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = USSService.CreateUniversityStudentScore(&USS)
	if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败:" + err.Error(), c)
		return
	}
    response.OkWithMessage("创建成功", c)
}

// DeleteUniversityStudentScore 删除学成绩
// @Tags UniversityStudentScore
// @Summary 删除学成绩
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body example.UniversityStudentScore true "删除学成绩"
// @Success 200 {object} response.Response{msg=string} "删除成功"
// @Router /USS/deleteUniversityStudentScore [delete]
func (USSApi *UniversityStudentScoreApi) DeleteUniversityStudentScore(c *gin.Context) {
	ID := c.Query("ID")
	err := USSService.DeleteUniversityStudentScore(ID)
	if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("删除成功", c)
}

// DeleteUniversityStudentScoreByIds 批量删除学成绩
// @Tags UniversityStudentScore
// @Summary 批量删除学成绩
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
// @Router /USS/deleteUniversityStudentScoreByIds [delete]
func (USSApi *UniversityStudentScoreApi) DeleteUniversityStudentScoreByIds(c *gin.Context) {
	IDs := c.QueryArray("IDs[]")
	err := USSService.DeleteUniversityStudentScoreByIds(IDs)
	if err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("批量删除成功", c)
}

// UpdateUniversityStudentScore 更新学成绩
// @Tags UniversityStudentScore
// @Summary 更新学成绩
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body example.UniversityStudentScore true "更新学成绩"
// @Success 200 {object} response.Response{msg=string} "更新成功"
// @Router /USS/updateUniversityStudentScore [put]
func (USSApi *UniversityStudentScoreApi) UpdateUniversityStudentScore(c *gin.Context) {
	var USS example.UniversityStudentScore
	err := c.ShouldBindJSON(&USS)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = USSService.UpdateUniversityStudentScore(USS)
	if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("更新成功", c)
}

// FindUniversityStudentScore 用id查询学成绩
// @Tags UniversityStudentScore
// @Summary 用id查询学成绩
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param ID query uint true "用id查询学成绩"
// @Success 200 {object} response.Response{data=example.UniversityStudentScore,msg=string} "查询成功"
// @Router /USS/findUniversityStudentScore [get]
func (USSApi *UniversityStudentScoreApi) FindUniversityStudentScore(c *gin.Context) {
	ID := c.Query("ID")
	reUSS, err := USSService.GetUniversityStudentScore(ID)
	if err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败:" + err.Error(), c)
		return
	}
	response.OkWithData(reUSS, c)
}
// GetUniversityStudentScoreList 分页获取学成绩列表
// @Tags UniversityStudentScore
// @Summary 分页获取学成绩列表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data query exampleReq.UniversityStudentScoreSearch true "分页获取学成绩列表"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
// @Router /USS/getUniversityStudentScoreList [get]
func (USSApi *UniversityStudentScoreApi) GetUniversityStudentScoreList(c *gin.Context) {
	var pageInfo exampleReq.UniversityStudentScoreSearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	list, total, err := USSService.GetUniversityStudentScoreInfoList(pageInfo)
	if err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败:" + err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     list,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}

// GetUniversityStudentScorePublic 不需要鉴权的学成绩接口
// @Tags UniversityStudentScore
// @Summary 不需要鉴权的学成绩接口
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
// @Router /USS/getUniversityStudentScorePublic [get]
func (USSApi *UniversityStudentScoreApi) GetUniversityStudentScorePublic(c *gin.Context) {
    // 此接口不需要鉴权
    // 示例为返回了一个固定的消息接口，一般本接口用于C端服务，需要自己实现业务逻辑
    USSService.GetUniversityStudentScorePublic()
    response.OkWithDetailed(gin.H{
       "info": "不需要鉴权的学成绩接口信息",
    }, "获取成功", c)
}
